#include "line.h"
#include <QPainter>
#include <QColor>
#include <QBrush>
#include <QPen>
#include <QFrame>
#include <QVector>
line::line(QWidget *parent, float rate, int rotateflag) :
    QWidget(parent)
{
    this->rate = rate;
    this->rotateflag = rotateflag;
}

void line::paintEvent(QPaintEvent *)
{
    QPainter painter(this);

    painter.setPen(panelcolor);
    painter.setBrush(panelcolor);
    painter.scale(rate, rate);
    painter.drawRect(0, 0, 64, 64);
    painter.setPen(color);
    painter.setBrush(color);
    QVector<QRect> vector;
    if (rotateflag == 0)
    {
        vector.append(QRect(24, 5, 16, 9));
        vector.append(QRect(17, 14, 30, 9));
        vector.append(QRect(7, 23, 50, 31));
    }
    if (rotateflag == 1)
    {
        vector.append(QRect(7, 5, 50, 31));
        vector.append(QRect(17, 36, 30, 9));
        vector.append(QRect(24, 45, 16, 9));
    }
    painter.drawRects(vector);
}


QColor line::getColor()
{
    return this->color;
}

void line::setColor(QColor color)
{
    this->color = color;
}

QColor line::getPanelColor()
{
    return this->panelcolor;
}

void line::setPanelColor(QColor color)
{
    this->panelcolor = color;
}

